package com.sys.users.service.impl;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sys.common.pojo.ApiResponse;
import com.sys.common.pojo.ApiResponseEnum;
import com.sys.common.pojo.JSONEnum;
import com.sys.common.service.BaseServiceImpl;
import com.sys.common.util.ConstatFinalUtil;
import com.sys.common.util.PageInfoUtil;
import com.sys.users.dao.ICustomerDao;
import com.sys.users.dao.IScenicSpotAdminDao;
import com.sys.users.dao.IScenicSpotDao;
import com.sys.users.dao.ISuperSsaDao;
import com.sys.users.pojo.Customer;
import com.sys.users.pojo.ScenicSpot;
import com.sys.users.pojo.ScenicSpotAdmin;
import com.sys.users.pojo.SuperSsa;
import com.sys.users.service.IUsersDbService;

/**
 * 用户的service
 * @author 梦缠绵
 */
@Service("usersDbService")
public class UsersDbServiceImpl extends BaseServiceImpl implements IUsersDbService
{
	/**
	 * dao如何赋值 ~木有写Dao的实现类,无法去顶@Repository(仓库) ~session.getMapper();
	 */
	@Resource
	private ICustomerDao customerDao;
	@Resource
	private ISuperSsaDao superSsaDao;
	@Resource
	private IScenicSpotAdminDao scenicSpotAdminDao;
	@Resource
	private IScenicSpotDao scenicSpotDao;

	@Override
	public ApiResponse<Object> saveOneCustomerService(Customer customer)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		//添加管理员密码的时候,进行加密.
		customer.setPassword(this.encryptUtil.encodeStr(customer.getPassword()));
		/* 查询条件 */
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.clear();
		condMap.put("account", customer.getAccount());
		ApiResponse<Customer> apiRes = this.findOneCustomerService(condMap);
		/* 获取对象 */
		Customer adminRes = apiRes.getDataOneJava() ; 
		if(adminRes != null)
		{
			/* 用户名已经存在,请换一个 */
			apiResponse.setCode(ApiResponseEnum.INFO_EMAIL_EXISTS.getStatus());
			apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
			return apiResponse ; 
		}
		
		int res = this.customerDao.save(customer);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), customer.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> updateOneCustomerService(Customer customer)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		/* 查询条件 */
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.clear();
		condMap.put("account", customer.getAccount());
		ApiResponse<Customer> apiRes = this.findOneCustomerService(condMap);
		/* 获取对象 */
		Customer adminRes = apiRes.getDataOneJava() ; 
		if(adminRes != null && adminRes.getId() != customer.getId())
		{
			/* 用户名已经存在,请换一个 */
			apiResponse.setCode(ApiResponseEnum.INFO_EMAIL_EXISTS.getStatus());
			apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
			return apiResponse ; 
		}
		
		int res = this.customerDao.update(customer);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), customer.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> deleteOneCustomerService(Map<String, Object> condMap)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		int res = this.customerDao.delete(condMap);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Customer> findOneCustomerService(Map<String, Object> condMap)
	{
		ApiResponse<Customer> apiResponse = new ApiResponse<Customer>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		Map<String, Customer> data = new HashMap<String, Customer>();
		Customer customer = this.customerDao.findOne(condMap);
		if(customer != null)
		{
			data.put(ApiResponseEnum.NAME_ONE.getName(), customer);
		}
		
		/* 将结果放到JSON中 */
		apiResponse.setDataOne(data);
		apiResponse.setDataOneJava(customer);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse ; 
	}


	@Override
	public ApiResponse<Customer> findCondListCustomerService(PageInfoUtil pageInfoUtil, Map<String, Object> condMap)
	{
		ApiResponse<Customer> apiResponse = new ApiResponse<Customer>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		List<Customer> customerList = Collections.EMPTY_LIST;
		
		Map<String, List<Customer>> dataList = new HashMap<String, List<Customer>>();
		/* 对关键字进行模糊匹配 */
		if(condMap.get("keyword") != null && !"".equalsIgnoreCase(condMap.get("keyword") + ""))
		{
			condMap.put("keyword", "%" + condMap.get("keyword") + "%") ; 
		}
		
		/* 设置分页相关信息 */
		if(pageInfoUtil != null)
		{
			/* 设置分页信息 */
			Page page = PageHelper.startPage(pageInfoUtil.getCurrentPage(),pageInfoUtil.getPageSize());
			customerList = this.customerDao.findList(condMap) ; 
			pageInfoUtil.setTotalRecord(Integer.valueOf(page.getTotal() + ""));
			/* 向接口中放分页信息 */
			apiResponse.setPageInfoUtil(pageInfoUtil);
		}else
		{
			customerList = this.customerDao.findList(condMap) ; 
		}
		
		/* 将结果放到JSON中 */
		dataList.put(ApiResponseEnum.NAME_LIST.getName(), customerList);	
		apiResponse.setDataListJava(customerList);
		apiResponse.setDataList(dataList);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse; 
	}
	
	@Override
	public ApiResponse<Object> saveOneSuperSsaService(SuperSsa superSsa)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		//添加管理员密码的时候,进行加密.
		superSsa.setPassword(this.encryptUtil.encodeStr(superSsa.getPassword()));
		/* 查询条件 */
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.clear();
		condMap.put("account", superSsa.getAccount());
		ApiResponse<SuperSsa> apiRes = this.findOneSuperSsaService(condMap);
		/* 获取对象 */
		SuperSsa adminRes = apiRes.getDataOneJava() ; 
		if(adminRes != null)
		{
			/* 用户名已经存在,请换一个 */
			apiResponse.setCode(ApiResponseEnum.INFO_EMAIL_EXISTS.getStatus());
			apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
			return apiResponse ; 
		}
		
		int res = this.superSsaDao.save(superSsa);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), superSsa.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> updateOneSuperSsaService(SuperSsa superSsa)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		/* 查询条件 */
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.clear();
		condMap.put("account", superSsa.getAccount());
		ApiResponse<SuperSsa> apiRes = this.findOneSuperSsaService(condMap);
		/* 获取对象 */
		SuperSsa adminRes = apiRes.getDataOneJava() ; 
		if(adminRes != null && adminRes.getId() != superSsa.getId())
		{
			/* 用户名已经存在,请换一个 */
			apiResponse.setCode(ApiResponseEnum.INFO_EMAIL_EXISTS.getStatus());
			apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
			return apiResponse ; 
		}
		
		int res = this.superSsaDao.update(superSsa);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), superSsa.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> deleteOneSuperSsaService(Map<String, Object> condMap)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		int res = this.superSsaDao.delete(condMap);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<SuperSsa> findOneSuperSsaService(Map<String, Object> condMap)
	{
		ApiResponse<SuperSsa> apiResponse = new ApiResponse<SuperSsa>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		Map<String, SuperSsa> data = new HashMap<String, SuperSsa>();
		SuperSsa superSsa = this.superSsaDao.findOne(condMap);
		if(superSsa != null)
		{
			data.put(ApiResponseEnum.NAME_ONE.getName(), superSsa);
		}
		
		/* 将结果放到JSON中 */
		apiResponse.setDataOne(data);
		apiResponse.setDataOneJava(superSsa);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse ; 
	}


	@Override
	public ApiResponse<SuperSsa> findCondListSuperSsaService(PageInfoUtil pageInfoUtil, Map<String, Object> condMap)
	{
		ApiResponse<SuperSsa> apiResponse = new ApiResponse<SuperSsa>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		List<SuperSsa> superSsaList = Collections.EMPTY_LIST;
		
		Map<String, List<SuperSsa>> dataList = new HashMap<String, List<SuperSsa>>();
		/* 对关键字进行模糊匹配 */
		if(condMap.get("keyword") != null && !"".equalsIgnoreCase(condMap.get("keyword") + ""))
		{
			condMap.put("keyword", "%" + condMap.get("keyword") + "%") ; 
		}
		
		/* 设置分页相关信息 */
		if(pageInfoUtil != null)
		{
			/* 设置分页信息 */
			Page page = PageHelper.startPage(pageInfoUtil.getCurrentPage(),pageInfoUtil.getPageSize());
			superSsaList = this.superSsaDao.findList(condMap) ; 
			pageInfoUtil.setTotalRecord(Integer.valueOf(page.getTotal() + ""));
			/* 向接口中放分页信息 */
			apiResponse.setPageInfoUtil(pageInfoUtil);
		}else
		{
			superSsaList = this.superSsaDao.findList(condMap) ; 
		}
		
		/* 将结果放到JSON中 */
		dataList.put(ApiResponseEnum.NAME_LIST.getName(), superSsaList);	
		apiResponse.setDataListJava(superSsaList);
		apiResponse.setDataList(dataList);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse; 
	}
	
	@Override
	public ApiResponse<Object> saveOneScenicSpotAdminService(ScenicSpotAdmin scenicSpotAdmin)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		//添加管理员密码的时候,进行加密.
		scenicSpotAdmin.setPassword(this.encryptUtil.encodeStr(scenicSpotAdmin.getPassword()));
		/* 查询条件 */
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.clear();
		condMap.put("account", scenicSpotAdmin.getAccount());
		ApiResponse<ScenicSpotAdmin> apiRes = this.findOneScenicSpotAdminService(condMap);
		/* 获取对象 */
		ScenicSpotAdmin adminRes = apiRes.getDataOneJava() ; 
		if(adminRes != null)
		{
			/* 用户名已经存在,请换一个 */
			apiResponse.setCode(ApiResponseEnum.INFO_EMAIL_EXISTS.getStatus());
			apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
			return apiResponse ; 
		}
		
		int res = this.scenicSpotAdminDao.save(scenicSpotAdmin);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), scenicSpotAdmin.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> updateOneScenicSpotAdminService(ScenicSpotAdmin scenicSpotAdmin)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		/* 查询条件 */
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.clear();
		condMap.put("account", scenicSpotAdmin.getAccount());
		ApiResponse<ScenicSpotAdmin> apiRes = this.findOneScenicSpotAdminService(condMap);
		/* 获取对象 */
		ScenicSpotAdmin adminRes = apiRes.getDataOneJava() ; 
		if(adminRes != null && adminRes.getId() != scenicSpotAdmin.getId())
		{
			/* 用户名已经存在,请换一个 */
			apiResponse.setCode(ApiResponseEnum.INFO_EMAIL_EXISTS.getStatus());
			apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
			return apiResponse ; 
		}
		
		int res = this.scenicSpotAdminDao.update(scenicSpotAdmin);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), scenicSpotAdmin.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> deleteOneScenicSpotAdminService(Map<String, Object> condMap)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		int res = this.scenicSpotAdminDao.delete(condMap);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<ScenicSpotAdmin> findOneScenicSpotAdminService(Map<String, Object> condMap)
	{
		ApiResponse<ScenicSpotAdmin> apiResponse = new ApiResponse<ScenicSpotAdmin>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		Map<String, ScenicSpotAdmin> data = new HashMap<String, ScenicSpotAdmin>();
		ScenicSpotAdmin scenicSpotAdmin = this.scenicSpotAdminDao.findOne(condMap);
		if(scenicSpotAdmin != null)
		{
			data.put(ApiResponseEnum.NAME_ONE.getName(), scenicSpotAdmin);
		}
		
		/* 将结果放到JSON中 */
		apiResponse.setDataOne(data);
		apiResponse.setDataOneJava(scenicSpotAdmin);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse ; 
	}


	@Override
	public ApiResponse<ScenicSpotAdmin> findCondListScenicSpotAdminService(PageInfoUtil pageInfoUtil, Map<String, Object> condMap)
	{
		ApiResponse<ScenicSpotAdmin> apiResponse = new ApiResponse<ScenicSpotAdmin>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		List<ScenicSpotAdmin> scenicSpotAdminList = Collections.EMPTY_LIST;
		
		Map<String, List<ScenicSpotAdmin>> dataList = new HashMap<String, List<ScenicSpotAdmin>>();
		/* 对关键字进行模糊匹配 */
		if(condMap.get("keyword") != null && !"".equalsIgnoreCase(condMap.get("keyword") + ""))
		{
			condMap.put("keyword", "%" + condMap.get("keyword") + "%") ; 
		}
		
		/* 设置分页相关信息 */
		if(pageInfoUtil != null)
		{
			/* 设置分页信息 */
			Page page = PageHelper.startPage(pageInfoUtil.getCurrentPage(),pageInfoUtil.getPageSize());
			scenicSpotAdminList = this.scenicSpotAdminDao.findList(condMap) ; 
			pageInfoUtil.setTotalRecord(Integer.valueOf(page.getTotal() + ""));
			/* 向接口中放分页信息 */
			apiResponse.setPageInfoUtil(pageInfoUtil);
		}else
		{
			scenicSpotAdminList = this.scenicSpotAdminDao.findList(condMap) ; 
		}
		
		/* 将结果放到JSON中 */
		dataList.put(ApiResponseEnum.NAME_LIST.getName(), scenicSpotAdminList);	
		apiResponse.setDataListJava(scenicSpotAdminList);
		apiResponse.setDataList(dataList);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse; 
	}
	
	@Override
	public ApiResponse<Object> saveOneScenicSpotService(ScenicSpot scenicSpot)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		
		int res = this.scenicSpotDao.save(scenicSpot);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), scenicSpot.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> updateOneScenicSpotService(ScenicSpot scenicSpot)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		int res = this.scenicSpotDao.update(scenicSpot);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			dataMap.put(JSONEnum.ID.getName(), scenicSpot.getId());
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""), Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<Object> deleteOneScenicSpotService(Map<String, Object> condMap)
	{
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		int res = this.scenicSpotDao.delete(condMap);
		if (res > 0)
		{
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put(JSONEnum.EFFECT.getName(), res);
			apiResponse.setDataOne(dataMap);
			
			apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		} else
		{
			apiResponse.setCode(ApiResponseEnum.STATUS_FAILED.getStatus());
		}
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse;
	}

	@Override
	public ApiResponse<ScenicSpot> findOneScenicSpotService(Map<String, Object> condMap)
	{
		ApiResponse<ScenicSpot> apiResponse = new ApiResponse<ScenicSpot>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		Map<String, ScenicSpot> data = new HashMap<String, ScenicSpot>();
		ScenicSpot scenicSpot = this.scenicSpotDao.findOne(condMap);
		if(scenicSpot != null)
		{
			data.put(ApiResponseEnum.NAME_ONE.getName(), scenicSpot);
		}
		
		/* 将结果放到JSON中 */
		apiResponse.setDataOne(data);
		apiResponse.setDataOneJava(scenicSpot);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse ; 
	}


	@Override
	public ApiResponse<ScenicSpot> findCondListScenicSpotService(PageInfoUtil pageInfoUtil, Map<String, Object> condMap)
	{
		ApiResponse<ScenicSpot> apiResponse = new ApiResponse<ScenicSpot>();
		apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
		List<ScenicSpot> scenicSpotList = Collections.EMPTY_LIST;
		
		Map<String, List<ScenicSpot>> dataList = new HashMap<String, List<ScenicSpot>>();
		/* 对关键字进行模糊匹配 */
		if(condMap.get("keyword") != null && !"".equalsIgnoreCase(condMap.get("keyword") + ""))
		{
			condMap.put("keyword", "%" + condMap.get("keyword") + "%") ; 
		}
		
		/* 设置分页相关信息 */
		if(pageInfoUtil != null)
		{
			/* 设置分页信息 */
			Page page = PageHelper.startPage(pageInfoUtil.getCurrentPage(),pageInfoUtil.getPageSize());
			scenicSpotList = this.scenicSpotDao.findList(condMap) ; 
			pageInfoUtil.setTotalRecord(Integer.valueOf(page.getTotal() + ""));
			/* 向接口中放分页信息 */
			apiResponse.setPageInfoUtil(pageInfoUtil);
		}else
		{
			scenicSpotList = this.scenicSpotDao.findList(condMap) ; 
		}
		
		/* 将结果放到JSON中 */
		dataList.put(ApiResponseEnum.NAME_LIST.getName(), scenicSpotList);	
		apiResponse.setDataListJava(scenicSpotList);
		apiResponse.setDataList(dataList);
		apiResponse.setInfo(ConstatFinalUtil.INFO_JSON.getString(apiResponse.getCode() + ""),Collections.EMPTY_MAP);
		return apiResponse; 
	}
}
